chart = {
const selection = vl.selectSingle('Select')
.fields('Origin')
.bind({Origin: vl.menu(countries)});
const scatter_sq = width * 0.47;
const hist_width = width * 0.36;
const num_hist = 4;
const brush = vl.selectInterval().encodings('x').resolve('intersect');
const hist = vl.markBar()
.encode(
vl.x().fieldQ(vl.repeat('row'))
.bin({maxbins: 100, minstep: 1})
.axis({format: 'd', titleAnchor: 'start'}),
vl.y().count().title(null));
const hist_layer = vl.layer(
hist.select(brush).encode(vl.color().value('lightgrey')),
hist.transform(vl.filter(brush)))
.height((scatter_sq/num_hist)-(10*num_hist))
.width(hist_width)
.repeat({row: ['Cylinders', 'Displacement', 'Weight_in_lbs', 'Acceleration']});
const scatter = vl.markPoint()
.select(selection)
.transform(vl.filter(selection))
.encode(
vl.x().fieldQ("Horsepower"),
vl.y().fieldQ("Miles_per_Gallon"),
vl.color().if(brush, vl.value('steelblue')).value('grey'),
vl.opacity().if(brush, vl.value(0.8)).value(0.1),
vl.tooltip(['Name', 'Origin', 'Year'].concat(quant_columns))
)
.height(scatter_sq).width(scatter_sq);
return vl.hconcat(hist_layer, scatter)
.data(cars)
.render();
}